package kr.hkit.androidcomplete03.ch25;

import kr.hkit.androidcomplete03.R;
import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.IBinder;
import android.widget.Toast;

public class MusicService extends Service {
	 private static final String TAG = "MusicService"; 
	 MediaPlayer player; 
	@Override
	public IBinder onBind(Intent intent) {
		return null;
	}
	
	 public void onCreate() { 
	        player = MediaPlayer.create(this, R.raw.aaa); 
	        player.setLooping(false); // Set looping 
	    } 
	 
	    public void onDestroy() { 
	        Toast.makeText(this, "Music Service가 중지되었습니다.", Toast.LENGTH_LONG).show(); 
	        player.stop(); 
	    } 
	 
	    public int onStartCommand(Intent intent, int flags, int startid) { 
	        Toast.makeText(this, "Music Service가 시작되었습니다.", Toast.LENGTH_LONG).show(); 
	        player.start(); 
	        return START_STICKY; 
	    } 

}
